<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>角色</title>
    <link rel="stylesheet" href="/css/styletable.css" type="text/css"/>
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
    <script src="/layui/layui.all.js" charset="utf-8"></script>
    <script src="/js/jquery.2.1.4.js" charset="utf-8"></script>
</head>
<body>
<script>
    function stop() {
        if ($(".check:checked").size() == 0) {
            layer.alert('请至少选一项', {
                skin: 'layui-layer-molv'
                , closeBtn: 0
            });
        } else {
            $("#roleform").attr("action", "/role/stop").submit();
        }
    }

    function start() {
        if ($(".check:checked").size() == 0) {
            layer.alert('请至少选一项', {
                skin: 'layui-layer-molv'
                , closeBtn: 0
            });
        } else {
            $("#roleform").attr("action", "/role/start").submit();
        }
    }

    function edit() {
        if ($(".check:checked").size() != 1) {
            layer.alert('请选择一项', {
                skin: 'layui-layer-molv'
                , closeBtn: 0
            });
        } else {
            $("#roleform").attr("action", "/role/toedit").submit();
        }
    }

    function dele() {
        if ($(".check:checked").size() == 0) {
            layer.alert('请至少选一项', {
                skin: 'layui-layer-molv'
                , closeBtn: 0
            });
        } else {
            $("#roleform").attr("action", "/role/del").submit();
        }
    }
    function role() {
        if ($(".check:checked").size() != 1) {
            layer.alert('请选择一项', {
                skin: 'layui-layer-molv'
                , closeBtn: 0
            });
        } else {
            $("#roleform").attr("action", "/role/torole").submit();
        }
        //window.location.href="/page/author.jsp";
    }
</script>
<div style="margin: 10px 15px 0px 15px">
    <div style="margin-top: 1px;margin-left: 1px;margin-bottom: 10px">
        <button class="layui-btn" onclick="start();">启用</button>
        <button class="layui-btn layui-btn-danger" onclick="stop();">禁用</button>
        <a class="layui-btn layui-btn-normal" href="/role/toadd">添加</a>
        <button class="layui-btn layui-btn-edit" onclick="edit();">编辑</button>
        <button class="layui-btn layui-btn-warm" onclick="dele();">删除</button>
        <button class="layui-btn layui-btn-fun" onclick="role();">资源授权</button>
    </div>
    <form id="roleform">
        <table style="width: 100%">
            <tr>
                <th width="10%"></th>
                <th width="30%">角色名称</th>
                <th width="45%">描述</th>
                <th width="15%">状态</th>
            </tr>

            <c:forEach items="${roles}" var="role">
                <tr>
                    <td align="center"><input class="check" name="checks" value="${role.oid}" type="checkbox"/></td>
                    <td>${role.oname}</td>
                    <td>${role.odesc}</td>
                    <td align="center"><span
                            class="layui-btn layui-btn-mini <c:if test="${role.ostate=='禁用'}">layui-btn-danger</c:if>">${role.ostate}</span>
                    </td>
                </tr>
            </c:forEach>
        </table>
    </form>
</div>
</body>
</html>
